<?php
	$uri2 = $this->uri->segment(2);
	$uri3 = $this->uri->segment(3);
	$to_display = (strtolower(trim($uri2)) == 'eulogy' && !empty($uri3))? true:false;//to show or hide the message's info
	$recipients = Myuser_helper::getUserRecipients();
	$usertype = strtolower(trim(Myuser_helper::get_user_type($_SESSION['email'])));//vip,free or reseller
	if($usertype == 'free'):
		$recipient_info = Myuser_helper::get_recipient_user_id($_SESSION['email']);//get the user id and recipient id
		if(count($recipient_info) > 0){
			$messages1 = Myuser_helper::get_freeuser_messages($recipient_info);//message that is public or all totype
			$messages2 = Myuser_helper::get_freeuser_messages($recipient_info,true);
			$ctr_msg = count($messages1)+count($messages2);
		}else{
			$ctr_msg = 0;
		}//end if
	endif;

	//for user as executor
	$userData = Myuser_helper::getUserData();
	$userId = $userData->userid;
	$executorA = Myuser_helper::getExecutorProfiler($userId);
//
	//end for user as executor

?>

	<div id = "sidebar-area">
		<?php if($usertype == 'free'){ ?>
			<!-- for upgrade button -->
			<div id="base_path_u" style="display:none;"><?php echo base_url() ?></div>
			<div class="free_content_holder upgrade-btn" style="border:none;">
				<div class="button-left-bg"></div>
				<div class="button-mid-bg upgrade-btn-txt">
					<div style="font-weight:bold;margin:2px;">Upgrade to VIP account</div>
				</div>
				<div class="button-right-bg"></div>
				<div class="clear"></div>
			</div>

			<!-- end for upgrade button -->
			<!-- executor sidebar -->
			<?php if(!empty($executorA)){?>
			<div class="free_content_holder">
				<div class="fc_header_wrapper">
					<div id="top_txt_first" style="text-align:center;">Executor Page</div>
					<div id="top_txt_second">
						<div id="fc_exec_click_here" style="cursor:pointer;padding-left:30px;">
							<div id="fc_arr_down" class="fleft"></div>
							<div class="fleft">Click Here to View</div>
						</div>
						<div class="clear"></div>
					</div>
					<div id="fc_exec_rwrapper" style="display:none;">
						<form name="frm_fc" id="frm_exec_fc" method="post">
							<input type="hidden" name="fc_base" id="fc_base" value="<?php echo base_url();?>">
						<?php
							$x=0;
							foreach($executorA as $executor):
							$x++;
						?>
							<div class="fc_rcontainer">
								<div class="fc_thumbs fleft"><img src="<?php echo base_url();?>assets/images/<?php echo (!empty($info['picture']))?'useruploads/profile_photos/'.$info['picture']:'default.png';?>" alt="user photo"/></div>
								<div class="fleft fc_rname">
									<div><?php echo $executor['firstname']?></div>
									<div><?php echo $executor['lastname'];?></div>
								</div>
								<div class="clear"></div>
								<div class="fc_password_holder">
									<div class="fleft">Password:</div>
									<div class="fleft fc_pass_inp">
										<input type="password" name="r_pass_<?php echo $x;?>" class="fc_r_pass_exec"/>
										<input type="hidden" name="userid_<?php echo $x;?>" class="fc_r_userid_exec" value="<?php echo $this->encryption_lib->encode($executor['userid']);?>"/>
										<input type="hidden" name="indicator" class="fc_indicator" value="1"/>
										<a href="javascript:void(0);" class="fc_exec_passwordok">OK</a>
									</div>
									<div class="clear"></div>
								</div>
								<div class="notify_button" style="display:none;margin-left:10px;">
									<input type="button" value="Notify all recipients"  class="notify_btn"/>
								</div>
								<div class="msg_content"></div>
							</div>
						<?php endforeach;?>
						</form>
					</div>
				</div>
			</div>
			<?php }//end executor first endif ?>
			<!-- end executor sidebar -->
			<div class="free_content_holder">
				<div class="fc_header_wrapper">
					<div id="top_header"><h3>Recipients Section</h3></div>
					<div id="top_txt_first">You have <?php echo $ctr_msg;?> message(s).</div>
					<?php if(count($recipient_info) > 0){?>
						<div id="top_txt_second">
							<div id="fc_click_here">
								<div id="<?php echo ($to_display)? 'fc_arr_up':'fc_arr_down'?>" class="fleft"></div>
								<div class="fleft">Click Here to <?php echo ($to_display)? 'Hide':'View';?></div>
							</div>
							<div id="fc_counter" class="fright"><?php echo $ctr_msg;?></div>
							<div class="clear"></div>
						</div>
						<div id="fc_rwrapper" style="<?php echo ($to_display)?'display:block':'';?>">
							<form name="frm_fc" id="frm_fc" method="post">
								<input type="hidden" name="fc_base" id="fc_base" value="<?php echo base_url();?>">
							<?php

								$x=0;
								foreach($recipient_info as $info):
								$x++;
							?>
								<div class="fc_rcontainer">
									<div class="fc_thumbs fleft"><img src="<?php echo base_url();?>assets/images/<?php echo (!empty($info['picture']))?'useruploads/profile_photos/'.$info['picture']:'default.png';?>" alt="user photo"/></div>
									<div class="fleft fc_rname">
										<div><?php echo $info['firstname']?></div>
										<div><?php echo $info['lastname'];?></div>
									</div>
									<div class="clear"></div>
									<div class="fc_password_holder">
										<div class="fleft">Password:</div>
										<div class="fleft fc_pass_inp">
											<input type="password" name="r_pass_<?php echo $x;?>" class="fc_r_pass"/>
											<input type="hidden" name="userid_<?php echo $x;?>" class="fc_r_userid" value="<?php echo $this->encryption_lib->encode($info['userid']);?>"/>
											<a href="#" class="fc_passwordok">OK</a>
										</div>
										<div class="clear"></div>
									</div>
									<div class="msg_content"><div class="correct"><?php echo ($to_display && $uri3 == $this->encryption_lib->encode($info['userid']))? 'Authentication Success':'';?></div></div>
								</div>
							<?php endforeach;?>
							</form>
						</div>
					<?php }//end if?>
				</div>
			</div>
		<?php }/*end if type free*/?>
		<div class="fright ev_holder"  title="Your eulogy will be presented to all your loved ones at your wake by your executors.">
			<div class="ev_wrapper">
				<div class="ev_arrow fleft"></div>
				<div class="fleft ev_txt_holder"><a href="<?php echo base_url();?>profile/eulogy_video" class="eu_txt">Eulogy Video</a></div>
				<div class="cboth"></div>
			</div>
		</div>
		<div id = "sidebar-menu">
			<ul class = "message_menu">
				<h2>Messages</h2>
				<?php
					$typefromurl = strtolower($this->uri->segment(3));
					switch($usertype){
						case 'vip':
					?>
							<li id="msg-phot" title="Let your loved ones be touched by your unforgettable captured memories. This is where you can upload photos or capture images directly from your webcam." class="<?php echo ($typefromurl == 'photos')? 'current':'';?>"><a href = "<?php echo base_url();?>messages/type/photos"><span id = "c-photos"><span class="c-counter"><?php echo myuser_helper::countMsg('photos');?></span></span>Photos</a></li>
							<li id="msg-vide" title="Memory is a way of holding onto the things you love, the things you are, the things you never want to lose. Upload your videos and your loved ones will forever remember you..." class="<?php echo ($typefromurl == 'videos')? 'current':'';?>"><a href = "<?php echo base_url();?>messages/type/videos"><span id = "c-videos"><span class="c-counter"><?php echo myuser_helper::countMsg('videos');?></span></span>Videos</a></li>
							<li id="msg-note" title="Write a note and tell your loved ones how much you love and care for them." class="<?php echo ($typefromurl == 'notes')? 'current':'';?>"><a href = "<?php echo base_url();?>messages/type/notes"><span id = "c-notes"><span class="c-counter"><?php echo myuser_helper::countMsg('notes');?></span></span>Notes</a></li>
							<li id="msg-docu" title="Important documents are as valuable as gold. Let your loved ones know that you have something entrusted for them and they are worthy enough to receive this." class="<?php echo ($typefromurl == 'documents')? 'current':'';?>"><a href = "<?php echo base_url();?>messages/type/documents"><span id = "c-documents"><span class="c-counter"><?php echo myuser_helper::countMsg('documents');?></span></span>Documents</a></li>
							<li id="msg-jour" title="Every man's memory is his private literature. Create your journal and let your loved ones be surprised with your real story." class="<?php echo ($typefromurl == 'journal')? 'current':'';?>"><a href = "<?php echo base_url();?>messages/type/journal"><span id = "c-journal"><span class="c-counter"><?php echo myuser_helper::countMsg('journal');?></span></span>Journal</a></li>
				<?php
						break;//end of case vip
						case 'free':
				?>
							<li id="msg-note" title="Write a note and tell your loved ones how much you love and care for them." class="<?php echo ($typefromurl == 'notes')? 'current':'';?>"><a href = "<?php echo base_url();?>messages/type/notes"><span id = "c-notes"><span class="c-counter"><?php echo myuser_helper::countMsg('notes');?></span></span>Notes</a></li>
				<?php
						break;//end of case free
						case 'reseller':

						break;//end of case reseller
					}//end switch
				?>

			</ul>
			<ul class = "recepients_menu">
				<?php if ((isset($records->password_setup_status)) && ($records->password_setup_status!=0)):?>
					<div class="fright">
						<div class="fleft"><h2>Recipients</h2></div>
						<div id="rep_counter" class="fleft"><?php echo count($recipients);?></div>
					</div>

					<input type="hidden" id="inp_rcounter" name="inp_rcounter" value="<?php echo count($recipients);?>" />
					<div class="clear"></div>
					<li id="rec-view" title="View and manage your recipients." class="<?php echo (strtolower($this->uri->segment(1)) == 'recipients' && trim($this->uri->segment(2)) == '')? 'current':'';?>"><a href="<?php echo base_url();?>recipients" id="a_recipients">View Recipients</a></li>
					<li id="rec-add" title="Add recipients and choose your executors who will be the ones to notify your recipients about your eulogy profile and messages. You must have more than 2 executors." class="<?php echo (strtolower($this->uri->segment(2)) == 'add_recipients')? 'current':'';?>"><a href="<?php echo base_url();?>recipients/add_recipients">Add recipients</a></li>
				<?php endif;?>
				<li id="rec-reme" title="Leave flowers and post your thoughts and pictures of your missed loved ones. This will also be the place where recipients will post about you." class="<?php echo (($usertype == 'free' && strtolower($this->uri->segment(1)) == 'profile' && $this->uri->segment(2) == '') || (strtolower($this->uri->segment(2)) == 'remembrance_wall'))? 'current':'';?>"><a href="<?php echo base_url();?>profile/remembrance_wall">Remembrance Wall</a></li>
			</ul>
		</div>
	</div>
</div><!--end of sideright-->
